<?php
/**
 * Base64对象
 *
 * @version $Id: IBase64.php 312 2008-04-23 16:29:38Z iwind $
 * @package util.lang
 * @since 0.0.3
 */
class IBase64 extends IObject {
	private $base64String;
	
	/**
	 * 构造器
	 *
	 * @param string $base64String Base64编码后的字符串
	 */
	public function __construct($base64String) {
		$this->base64String = $base64String;
	}
	
	/**
	 * 取得源字符串
	 *
	 * @return string
	 */
	public function getSource() {
		return base64_decode($this->base64String);
	}
	
	/**
	 * 将当前对象转换成字符串
	 *
	 * @return string
	 */
	public function __toString() {
		return $this->base64String;
	}
	
	/**
	 * 将字符串转换为IBase64对象
	 *
	 * @param string $sourceString 源字符串
	 * @return IBase64
	 */
	public static function toBase64($sourceString) {
		return new self(base64_encode($sourceString));
	}
}

?>